package iso3.pt.action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

import iso3.pt.dao.IncorrectPasswordException;
import iso3.pt.dao.UserNotFoundException;
import iso3.pt.model.Alumno;
import iso3.pt.model.Evaluacion;
import iso3.pt.model.Profesor;
import iso3.pt.service.PtDaoService;
import iso3.pt.service.PtService;

import java.util.Map;
import java.util.Set;


public class Unenrol  extends ActionSupport {

    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private PtService service = new PtDaoService();
	
	// Datos preparados para que los lea el JSP
	private Alumno alumno = null;
	private int codAsig = 0;
	private Set<Evaluacion> notas = null;

	public String execute() throws Exception 
	{
		// Obtener alumno
		@SuppressWarnings("rawtypes")
		Map session = ActionContext.getContext().getSession();
		alumno = (Alumno) session.get("alumno");
		
		// Obtener asignatura
		codAsig = getCodAsig();
		
		// Matricular
		service.desmatricular(alumno.getDni(), codAsig);
		
		return SUCCESS;
	}


    // ---- Username property ----

    /**
     * <p>Field to store User username.</p>
     * <p/>
     */
    private String username = null;


    /**
     * <p>Provide User username.</p>
     *
     * @return Returns the User username.
     */
    public String getUsername() {
        return username;
    }

    /**
     * <p>Store new User username</p>
     *
     * @param value The username to set.
     */
    public void setUsername(String value) {
        username = value;
    }

    // ---- Username property ----

    /**
     * <p>Field to store User password.</p>
     * <p/>
     */
    private String password = null;


    /**
     * <p>Provide User password.</p>
     *
     * @return Returns the User password.
     */
    public String getPassword() {
        return password;
    }

    /**
     * <p>Store new User password</p>
     *
     * @param value The password to set.
     */
    public void setPassword(String value) {
        password = value;
    }
    
	private String selector = null;
    
	public String getSelector() 
	{
		return selector;
	}

	public void setSelector(String selector) 
	{
		this.selector = selector;
	}

	public int getCodAsig()
	{
		return codAsig;
	}

	public void setCodAsig(int codAsig)
	{
		this.codAsig = codAsig;
	}

}
